package org.millioncall.yueyoga.admin.service.impl;

import java.util.List;

import org.millioncall.openplatform.common.PaginatedList;
import org.millioncall.openplatform.util.StringUtils;
import org.millioncall.yueyoga.admin.dao.HallDAO;
import org.millioncall.yueyoga.admin.model.Hall;
import org.millioncall.yueyoga.admin.service.HallService;
import org.springframework.stereotype.Service;

@Service
public class HallServiceImpl implements HallService {

	private HallDAO hallDAO;

	@Override
	public List<Hall> findHalls() {
		return hallDAO.findHalls();
	}

	public HallDAO getHallDAO() {
		return hallDAO;
	}

	public void setHallDAO(HallDAO hallDAO) {
		this.hallDAO = hallDAO;
	}

	@Override
	public boolean saveHall(Hall hall) {
		int i = hallDAO.insert(hall);
		if (i > 0) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public Hall findByName(String name) {
		return hallDAO.findByName(name);
	}

	@Override
	public Hall findByCode(String code) {
		return hallDAO.findByCode(code);
	}

	@Override
	public PaginatedList<Hall> getStatusInPage(int start, int limit) {
		return hallDAO.getStatusInPage(start, limit);
	}

	@Override
	public boolean updateHall(Hall hall) {
		return hallDAO.updateHallById(hall) > 0;
	}

	@Override
	public void deleteHallByIds(Integer[] deids) {
		if (deids == null || deids.length == 0) {
			throw new RuntimeException(" 未提交要删除演讲者的编号");
		} else {
			this.hallDAO.deleteByIds(deids);
		}
	}
	public List<Hall> findHallsByGroupId(String strGpId) {
		int gpId = 0;
		if (StringUtils.isNotBlank(strGpId)) {
			gpId = Integer.parseInt(strGpId);
		}
		return hallDAO.findHallsByGroupId(gpId);
	}

}
